/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.sales.hanserver.action.hancadsa.behavior;

import static br.com.sales.hanserver.action.hancadsa.HanCadSAServerConsts.GET_DATA_PRODUCT;
import br.com.sales.hanserver.dao.Dao;
import static br.com.sales.hanserver.dao.Dao.closeConn;
import static br.com.sales.hanserver.dao.Dao.getConn;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author v
 */
public class GetDataProduct extends Dao {

    public GetDataProduct() {
    }

    public Map getData(Long sequence) {
        Map resultData = new LinkedHashMap();
        try {
            PreparedStatement st = getConn().prepareStatement(GET_DATA_PRODUCT);
            st.setLong(1, sequence);

            ResultSet rs = st.executeQuery();
            while (rs.next()) {
                resultData.put("PRICE", rs.getDouble("PRICE"));
                resultData.put("COUNT", rs.getInt("COUNT"));
                resultData.put("MIN", rs.getInt("MIN"));
            }

            return resultData;

        } catch (Exception ex) {
            Logger.getLogger(GetDataProduct.class.getName()).log(Level.SEVERE, "Error getData", ex);
        } finally {
            closeConn();
        }
        return resultData;
    }
}
